/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package extension.tan.handler;

import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;
import extension.game.room.Player;
import extension.room.tan.TanExtension;
import extension.room.tan.TanGame;

/**
 *
 * @author daz
 */
public class RegisterAttackHandler extends BaseClientRequestHandler {
    
    @Override
    public void handleClientRequest(User user, ISFSObject params) {
        TanExtension ext = (TanExtension) getParentExtension();
        TanGame game = ext.getGame();
        int seatPos = -1;
        Player[] listPlayers = game.getListPlayers();
        for (int i = 0; i < game.getMaxPlayer(); i++) {
            if (listPlayers[i] != null && listPlayers[i].getUser().equals(user)) {
                seatPos = i;
                break;
            }
        }
        if (seatPos != -1) {
            game.addAttacker(seatPos);
        }
    }
}
